package com.probiz.estore.common.model.content.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.content.Advertisement;
import com.probiz.estore.common.model.content.ProductAdvertisement;

public class ProductAdvertisementTbl extends com.probiz.estore.core.model.BaseObject implements Serializable {

    protected Integer productAdvertisementId;
    protected Integer categoryId;
    protected Short  isSubIncluded;
	protected Advertisement advertisement;


	/**
	 * Default Empty Constructor for class ProductAdvertisement
	 */
	public ProductAdvertisementTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ProductAdvertisement
	 */
	public ProductAdvertisementTbl (
		 Integer in_productAdvertisementId
        ) {
		this.setProductAdvertisementId(in_productAdvertisementId);
    }

	
	public Advertisement getAdvertisement () {
		return advertisement;
	}	
	
	public void setAdvertisement (Advertisement in_advertisement) {
		this.advertisement = in_advertisement;
	}
    

	/**
	 * 
	 * @return Integer
     * @hibernate.id column="productAdvertisementId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getProductAdvertisementId() {
		return this.productAdvertisementId;
	}
	
	/**
	 * Set the productAdvertisementId
	 */	
	public void setProductAdvertisementId(Integer aValue) {
		this.productAdvertisementId = aValue;
	}	

	/**
	 * 
	 * @return Integer
	 */
	public Integer getAdvertisementId() {
		return this.getAdvertisement()==null?null:this.getAdvertisement().getAdvertisementId();
	}
	
	/**
	 * Set the advertisementId
	 */	
	public void setAdvertisementId(Integer aValue) {
	    if (aValue==null) {
	    	advertisement = null;
	    } else{
	        advertisement = new Advertisement(aValue);
	        advertisement.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	public Integer getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}


	public Short getIsSubIncluded() {
		return isSubIncluded;
	}

	public void setIsSubIncluded(Short isSubIncluded) {
		this.isSubIncluded = isSubIncluded;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ProductAdvertisement)) {
			return false;
		}
		ProductAdvertisement rhs = (ProductAdvertisement) object;
		return new EqualsBuilder()
				.append(this.productAdvertisementId, rhs.productAdvertisementId)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.productAdvertisementId) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("productAdvertisementId", this.productAdvertisementId) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "productAdvertisementId";
	}
	
}